﻿//Write a method that counts how many times given number appears in given array.
//Write a test program to check if the method is working correctly.


using System;
using System.Text;

public class NumberCount
{
    public static void Main()
    {
        Console.WriteLine("Enter array length");
        int integer = int.Parse(Console.ReadLine());
        Console.WriteLine("Enter integer");
        int number = int.Parse(Console.ReadLine());
        Random rand = new Random();
        int[] array = new int[integer];
        for (int i = 0; i < array.Length; i++)
        {
            array[i] = rand.Next(-10, 50);
        }

        int count = Count(array, number);
        Console.WriteLine("Number {0} apears {1} times in array", number, count);
    }

    public static int Count(int[] array, int number)
    {
        int countResult = 0;

        for (int i = 0; i < array.Length; i++)
        {
            if (array[i] == number)
            {
                countResult++;
            }
        }

        return countResult;
    }
}